/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { useEffect } from 'react';
import type { Location } from 'umi';
import { useLocation } from 'umi';

/**
 * @description 开启友盟统计
 */
export function useUma() {
  const location: Location = useLocation();
  const { pathname } = location;

  useEffect(() => {
    if (window.aplus_queue && pathname) {
      window.aplus_queue.push({
        action: 'aplus.sendPV',
        arguments: [{ is_auto: false }],
      });
    }
  }, [pathname]);
}
